package com.digdes.calendar.gwt.client.widget;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class CreateFileDialog extends DialogBox {
	
	public CreateFileDialog(){
		VerticalPanel vp = new VerticalPanel();
		HorizontalPanel hp = new HorizontalPanel();
		
		vp.setSize("100px", "100px");
		
		setAnimationEnabled(true);
		setGlassEnabled(true);

		final FileUpload fu = new FileUpload();
		
		
		Button uploadButton = new Button("Upload");
		Button close = new Button("Close");
		
		uploadButton.setSize("100px", "30px");
		close.setSize("100px", "30px");
		
		uploadButton.addClickHandler(new ClickHandler() {
			
			//@Override
			public void onClick(ClickEvent event) {
				String filename = fu.getFilename();
				if(filename.length()==0){
					Window.alert("Error, choose file");
				}
				else{
					Window.alert("Successful");
				}
				
				
			}
		});
		
		close.addClickHandler(new ClickHandler() {
			
			//@Override
			public void onClick(ClickEvent event) {
				CreateFileDialog.this.hide();
				
				
			}
		});
		
		vp.add(fu);
		hp.add(uploadButton);
		hp.add(close);
		vp.add(hp);
		setWidget(vp);
	
	}
	
public void show(){
		
		super.show();
	}
	
	
	
}
